<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>测试json字符串</title>
		<script>
			//4.json字符串和js对象互转--JSON工具
			var d=JSON.parse('[{"firstname":"jack","lastname":"joe"},{"firstname":"rose","lastname":"gaga"}]')
			console.log(d);
			console.log(d[1].lastname)
			console.log(d[0].firstname)
			var d1=JSON.stringify(d);
			console.log(d1)
			//3.定义json数组
			var c='[{"firstname":"jack","lastname":"joe"},{"firstname":"rose","lastname":"gaga"}]'
			console.log(c)
			console.log(c.length)
			//2.定义json对象
			var b='{"firstname":"jack","lastname":"joe"}'
			console.log(b)
			console.log(b.charAt(0))
			console.log(b.length)
			//1.定义json字符串
			var a='"firstname":"jack"';
			console.log(a)
			console.log(a.length)
			console.log(a.concat(123))
			console.log(a.substr(3))
		</script>
	</head>
	<body>
	</body>
</html>
